package com.zeekr.orm.common;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import java.io.Serializable;

/**
 * 通用返回类
 *
 * @author 吴文杰
 * @version 1.0
 * @since 2024/7/10 23:24
 */
@ApiModel(description = "返回实体")
public class BaseResponse<T> implements Serializable {

  @ApiModelProperty(value = "返回代码")
  private int code;

  @ApiModelProperty(value = "返回数据")
  private T data;

  @ApiModelProperty(value = "返回提示信息")
  private String message;

  public BaseResponse(int code, T data, String message) {
    this.code = code;
    this.data = data;
    this.message = message;
  }

  public BaseResponse(int code, T data) {
    this(code, data, "");
  }

  public BaseResponse(ErrorCode errorCode) {
    this(errorCode.getCode(), null, errorCode.getMessage());
  }

  public int getCode() {
    return code;
  }

  public void setCode(int code) {
    this.code = code;
  }

  public T getData() {
    return data;
  }

  public void setData(T data) {
    this.data = data;
  }

  public String getMessage() {
    return message;
  }

  public void setMessage(String message) {
    this.message = message;
  }
}
